{-# LANGUAGE CPP, TemplateHaskell #-}
-----------------------------------------------------------------------------
--
-- Module      :  Main
-- Copyright   :
-- License     :  AllRightsReserved
--
-- Maintainer  :
-- Stability   :
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------

module Main (
    main
) where

import System.IO
import Data.List.Split
import GHC.Exts
import Control.Monad

sentences :: String -> [String]
sentences = splitOn "."

countAndSortSentences :: [String] -> [(String, Int)]
countAndSortSentences sents = sortWith snd $ filter (\el -> snd el > 0) $ map generatePair sents

generatePair :: String -> (String, Int)
generatePair s = (s, length (words s))

main = do
        contents <- readFile "input.txt"
        let sentencesArray =  countAndSortSentences $ sentences contents
        forM_ sentencesArray (\sent ->
                putStrLn ( show ( snd sent ) ++ ": " ++ (fst sent))
            )

